package com.atguigu.springcloud.user.impl;

import com.atguigu.springcloud.extend.RedisService;
import com.atguigu.springcloud.user.ISystemUser;

import java.util.List;
import java.util.Map;

/**
 * @author xiaolong
 * @version 1.0
 * @description: 权限user
 * @date 2021/10/19 15:02
 */
public class AuthClientUserImpl implements ISystemUser {

    private String username;
    private String userAccout;
    private String userOrgCode;
    private String token;
    private final RedisService service;

    public AuthClientUserImpl(String gAuth, String token, RedisService service) {
        super();
        if (gAuth != null && !gAuth.equals("")) {
            String[] split = gAuth.split("&");
            if (split.length > 0) {
                this.username = split[0];
            }
            if (split.length > 1) {
                this.userAccout = split[1];
            }
            if (split.length > 2) {
                this.userOrgCode = split[2];
            }
        }
        if (token != null && !token.equals("")) {
            String[] s = token.split(" ");
            if (s.length > 1) {
                this.token = s[1];
            } else {
                this.token = s[0];
            }
        }
        this.service = service;
    }


    AuthClientUserImpl() {
        super();
        this.username = "超级管理员";
        this.userOrgCode = "ROOT";
        this.userAccout = "admin";
        this.service = null;
    }


    @Override
    public String getUserName() {
        return this.username;
    }

    @Override
    public String getUserAccout() {
        return this.userAccout;
    }

    @Override
    public String getUserOrgCode() {
        return this.userOrgCode;
    }

    @Override
    public List<String> getSuperiorOrgCodes() {
        return null;
    }

    @Override
    public List<String> getRoles() {
        return null;
    }

    @Override
    public Object get(String key, Object defValue) {
        return null;
    }

    @Override
    public <T> T get(String key, Class<T> clazz) {
        return null;
    }

    @Override
    public String getToken() {
        return this.token;
    }

    @Override
    public Map<String, Object> getUserInfoMap() {
        return null;
    }
}
